{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 7.3 \u7ed9\u51fd\u6570\u53c2\u6570\u589e\u52a0\u5143\u4fe1\u606f\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u95ee\u9898\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f60\u5199\u597d\u4e86\u4e00\u4e2a\u51fd\u6570\uff0c\u7136\u540e\u60f3\u4e3a\u8fd9\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u589e\u52a0\u4e00\u4e9b\u989d\u5916\u7684\u4fe1\u606f\uff0c\u8fd9\u6837\u7684\u8bdd\u5176\u4ed6\u4f7f\u7528\u8005\u5c31\u80fd\u6e05\u695a\u7684\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u5e94\u8be5\u600e\u4e48\u4f7f\u7528\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u89e3\u51b3\u65b9\u6848\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f7f\u7528\u51fd\u6570\u53c2\u6570\u6ce8\u89e3\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u529e\u6cd5\uff0c\u5b83\u80fd\u63d0\u793a\u7a0b\u5e8f\u5458\u5e94\u8be5\u600e\u6837\u6b63\u786e\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u3002\n\u4f8b\u5982\uff0c\u4e0b\u9762\u6709\u4e00\u4e2a\u88ab\u6ce8\u89e3\u4e86\u7684\u51fd\u6570\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def add(x:int, y:int) -> int:\n    return x + y"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "python\u89e3\u91ca\u5668\u4e0d\u4f1a\u5bf9\u8fd9\u4e9b\u6ce8\u89e3\u6dfb\u52a0\u4efb\u4f55\u7684\u8bed\u4e49\u3002\u5b83\u4eec\u4e0d\u4f1a\u88ab\u7c7b\u578b\u68c0\u67e5\uff0c\u8fd0\u884c\u65f6\u8ddf\u6ca1\u6709\u52a0\u6ce8\u89e3\u4e4b\u524d\u7684\u6548\u679c\u4e5f\u6ca1\u6709\u4efb\u4f55\u5dee\u8ddd\u3002\n\u7136\u800c\uff0c\u5bf9\u4e8e\u90a3\u4e9b\u9605\u8bfb\u6e90\u7801\u7684\u4eba\u6765\u8bb2\u5c31\u5f88\u6709\u5e2e\u52a9\u5566\u3002\u7b2c\u4e09\u65b9\u5de5\u5177\u548c\u6846\u67b6\u53ef\u80fd\u4f1a\u5bf9\u8fd9\u4e9b\u6ce8\u89e3\u6dfb\u52a0\u8bed\u4e49\u3002\u540c\u65f6\u5b83\u4eec\u4e5f\u4f1a\u51fa\u73b0\u5728\u6587\u6863\u4e2d\u3002"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "help(add)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5c3d\u7ba1\u4f60\u53ef\u4ee5\u4f7f\u7528\u4efb\u610f\u7c7b\u578b\u7684\u5bf9\u8c61\u7ed9\u51fd\u6570\u6dfb\u52a0\u6ce8\u89e3(\u4f8b\u5982\u6570\u5b57\uff0c\u5b57\u7b26\u4e32\uff0c\u5bf9\u8c61\u5b9e\u4f8b\u7b49\u7b49)\uff0c\u4e0d\u8fc7\u901a\u5e38\u6765\u8bb2\u4f7f\u7528\u7c7b\u6216\u8005\u5b57\u7b26\u4e32\u4f1a\u6bd4\u8f83\u597d\u70b9\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u8ba8\u8bba\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u51fd\u6570\u6ce8\u89e3\u53ea\u5b58\u50a8\u5728\u51fd\u6570\u7684 __annotations__ \u5c5e\u6027\u4e2d\u3002\u4f8b\u5982\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "add.__annotations__"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5c3d\u7ba1\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u53ef\u80fd\u6709\u5f88\u591a\u79cd\uff0c\u4f46\u662f\u5b83\u4eec\u7684\u4e3b\u8981\u7528\u9014\u8fd8\u662f\u6587\u6863\u3002\n\u56e0\u4e3apython\u5e76\u6ca1\u6709\u7c7b\u578b\u58f0\u660e\uff0c\u901a\u5e38\u6765\u8bb2\u4ec5\u4ec5\u901a\u8fc7\u9605\u8bfb\u6e90\u7801\u5f88\u96be\u77e5\u9053\u5e94\u8be5\u4f20\u9012\u4ec0\u4e48\u6837\u7684\u53c2\u6570\u7ed9\u8fd9\u4e2a\u51fd\u6570\u3002\n\u8fd9\u65f6\u5019\u4f7f\u7528\u6ce8\u89e3\u5c31\u80fd\u7ed9\u7a0b\u5e8f\u5458\u66f4\u591a\u7684\u63d0\u793a\uff0c\u8ba9\u4ed6\u4eec\u53ef\u4ee5\u6b63\u786e\u7684\u4f7f\u7528\u51fd\u6570\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u53c2\u80039.20\u5c0f\u8282\u7684\u4e00\u4e2a\u66f4\u52a0\u9ad8\u7ea7\u7684\u4f8b\u5b50\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u5229\u7528\u6ce8\u89e3\u6765\u5b9e\u73b0\u591a\u5206\u6d3e(\u6bd4\u5982\u91cd\u8f7d\u51fd\u6570)\u3002"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.1"
    },
    "toc": {
      "base_numbering": 1,
      "nav_menu": {},
      "number_sections": true,
      "sideBar": true,
      "skip_h1_title": true,
      "title_cell": "Table of Contents",
      "title_sidebar": "Contents",
      "toc_cell": false,
      "toc_position": {},
      "toc_section_display": true,
      "toc_window_display": true
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}